<?php

class apiactionlog_finder_erplog{

    public function __construct($app)
    {
        $this->app = $app;
    }

    var $detail_basic = '详情';
    public $detail_edit_order = COLUMN_IN_HEAD;
    public $detail_edit_width = 30;
    public function detail_basic($id){
        $render = app::get('apiactionlog')->render(); 
        $api_model = kernel::single('apiactionlog_mdl_erplog');
        $loglist = $api_model->getList('*',array('erplog_id'=>$id));
        $apilog['msg_id']=$loglist[0]['msg_id'];
        $apilog['task_name']=$loglist[0]['task_name'];
        $apilog['mingxi'] = unserialize($loglist[0]['mingxi']);
        $apilog['status'] = $loglist[0]['status'];
        foreach ($apilog['mingxi'] as $key => $value) {
            $mingxi .= '商品编码:'.$value['bn'].",<br>  ";
        }
        $apilog['mingxi'] = $mingxi;

        $apilog['msg'] = $loglist[0]['msg'];
        // 批量同步成功的msg_id
        if (isset($loglist[0]['msg_id'])){
            $render->pagedata['batch_msg_id'] = $loglist[0]['msg_id'];
        }

        $apilog['params'] = unserialize($loglist[0]['params']);
        $apilog['send_api_name'] = $loglist[0]['worker'];// API名称
        foreach($apilog['params'] as $key=>$val){
            $str_params .= $key."=".$val.",<br>  ";
        }

        $apilog['send_api_params'] = $str_params;
        $render->pagedata['apilog'] = $apilog;
        return $render->display('admin/erpdetail.html');
    }

    var $column_editbutton = '操作';
    public $column_editbutton_order = COLUMN_IN_HEAD;
    public $column_editbutton_width = 70;
    public function column_editbutton($row)
    {
        if ($row['status'] == 'fail' ){
            $str_operation = '<a icon="sss.ccc" href="index.php?app=apiactionlog&ctl=admin_erplog&act=re_request&erplog_id=' . $row['erplog_id'] .' label="重试"><span><!--todo ICON-->' . app::get('b2c')->_('重试') . '</span></a>';
        }else{
            $str_operation = "";
        }

        return $str_operation;
    }
}
?>
